package com.fldx.baseboot.web.business.service.impl;
import java.util.Arrays;
import java.util.List;
        import com.fldx.baseboot.common.utils.DateUtils;
import com.fldx.baseboot.web.business.dao.ComplaintsSuggestionsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fldx.baseboot.web.domain.ComplaintsSuggestions;
import com.fldx.baseboot.web.business.service.IComplaintsSuggestionsService;

/**
 * 信息收集Service业务层处理
 *
 * @author 范书铭
 * @date 2024-08-08
 */
@Service
public class ComplaintsSuggestionsServiceImpl implements IComplaintsSuggestionsService {
    @Autowired
    private ComplaintsSuggestionsDao complaintsSuggestionsDao;

    /**
     * 查询信息收集详情
     *
     * @param id 信息收集主键
     * @return 信息收集
     */
    @Override
    public ComplaintsSuggestions selectComplaintsSuggestionsById(Long id) {
        return complaintsSuggestionsDao.findById(id).orElseThrow(() -> new RuntimeException("数据不存在"));
    }

    /**
     * 查询信息收集列表
     *
     * @param complaintsSuggestions 信息收集
     * @return 信息收集
     */
    @Override
    public List<ComplaintsSuggestions> selectComplaintsSuggestionsList(ComplaintsSuggestions complaintsSuggestions) {
        return complaintsSuggestionsDao.getComplaintsSuggestionsList(complaintsSuggestions);
    }

    /**
     * 新增信息收集
     *
     * @param complaintsSuggestions 信息收集
     * @return 结果
     */
    @Override
    public ComplaintsSuggestions insertComplaintsSuggestions(ComplaintsSuggestions complaintsSuggestions) {
                complaintsSuggestions.setCreateTime(DateUtils.getNowDate());
            return complaintsSuggestionsDao.save(complaintsSuggestions);
    }

    /**
     * 修改信息收集
     *
     * @param complaintsSuggestions 信息收集
     * @return 结果
     */
    @Override
    public ComplaintsSuggestions updateComplaintsSuggestions(ComplaintsSuggestions complaintsSuggestions) {
                complaintsSuggestions.setUpdateTime(DateUtils.getNowDate());
        return complaintsSuggestionsDao.save(complaintsSuggestions);
    }

    /**
     * 批量删除信息收集
     *
     * @param ids 需要删除的信息收集主键
     * @return 结果
     */
    @Override
    public void deleteComplaintsSuggestionsByIds(Long[] ids) {
        List<Long> idList = Arrays.asList(ids);
            complaintsSuggestionsDao.deleteAllByIdInBatch(idList);
    }

}
